suffix = '.groovy'
gwcScriptRoot = context.getRealPath('/chat')
gwcDomainRoot = context.getRealPath('/WEB-INF/src')

parseDir = {dir ->
	def result = new StringBuffer("{id : '${dir.name}', text : '${dir.name}', cls : 'folder', children : [")

	dir.eachDir {
		result << parseDir(it) + ','
	}
	dir.eachFile {
		if (!it.directory) {
			result << "{id : '${it.name}', text : '${it.name}', cls : 'file', leaf : true},"
		}
	}

	result = result[0..-2]
	result <<= ']}'

	result
}

println "[" + parseDir(new File(gwcScriptRoot)) + "]"